package teacher.service.impl;

import teacher.entity.Teacherc;
import teacher.service.TeachercService;

import java.util.Scanner;

public class TeachercServiceImpl implements TeachercService {
    public static Teacherc teacherc;
    public static int loginError;
    @Override
    public void initializeTeacherc(){
        teacherc=new Teacherc();
        teacherc.setLoginTName("teacher");
        teacherc.setLoginTPassword("123456");
        teacherc.setTeacherTName("教师");
        loginError=5;
    }
    @Override
    public void teachercLogin(){
        for(int error=1;error<=loginError;error++){
            System.out.println("------教师登录------");
            Scanner scanner=new Scanner(System.in);
            System.out.print("请输入教师账号：");
            String loginName= scanner.next();
            System.out.print("请输入教师密码：");
            String loginPassword= scanner.next();
            if (teacherc.getLoginTName().equals(loginName) && teacherc.getLoginTPassword().equals(loginPassword)) {
                System.out.println("欢迎"+teacherc.getTeacherTName()+"登录");
                new TeachertServiceImpl().teachercMenu();
                return;
            }else {
                System.out.println("账号或密码错误请重新输入，以错误" + error + "次,超过" + loginError + "自动退出到登录页面");
                if (error==loginError){
                    System.out.println("尝试次数过多，自动退出中");
                    return;
                }
            }
        }
    }
}